package com.dxc.intern.service.impl;

import com.dxc.intern.entity.Page;
import com.dxc.intern.entity.PrimaryScreening;
import com.dxc.intern.entity.Resume;
import com.dxc.intern.mapper.PrimaryScreeningMapper;
import com.dxc.intern.service.PrimaryScreeningService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 初筛数据表 服务实现类
 * </p>
 *
 * @author zhangchengming
 * @since 2022-02-21
 */
@Service
public class PrimaryScreeningServiceImpl extends ServiceImpl<PrimaryScreeningMapper, PrimaryScreening> implements PrimaryScreeningService {
    
    @Autowired
    private PrimaryScreeningMapper primaryScreeningMapper;
    
    @Override
    public Page<Resume> page(Integer pageNo, Integer pageSize) {
        int total =primaryScreeningMapper.count();
        int index= pageNo == 1 ? 0 : (pageNo - 1) * pageSize;
        List<Resume> resumes=primaryScreeningMapper.page(index,pageSize);
        return new Page<Resume>(pageSize,pageNo,total,resumes);
    }

    @Override
    public Page<Resume> selectLike(Integer pageNo, Integer pageSize, Resume resume) {
        int total =primaryScreeningMapper.count();
        int index= pageNo == 1 ? 0 : (pageNo - 1) * pageSize;
        List<Resume> resumes=primaryScreeningMapper.selectLike(index,pageSize,resume);
        return new Page<Resume>(pageSize,pageNo,total,resumes);
    }


    @Override
    public boolean delete(Long id) {
        int i=primaryScreeningMapper.delete(id);
        return i>0;
    }

    @Override
    public boolean update(Resume resume) {
        int i=primaryScreeningMapper.update(resume);
        return i>0;
    }

    @Override
    public boolean addRoster(Resume resume) {
        int i=primaryScreeningMapper.addRoster(resume);
        return i>0;
    }
}
